

const arr = [];



//传入[0,1,2,3]代表第一行向左移动
function move(arr1 = [0,1,2,3]) {
    let ary = [];
    let ary1 = [];
    let k = 0;
    for (let ink = 0; ink < 4; ink++) {
        let element = arr1[ink];
        ary.push(Number(imgs[element].getAttribute('value')));
        
    }
     console.log(ary);
     
     
     for (let i=0; i<ary.length; i++) {

        if (ary[i] != 0) {
            // 判断j的值是不是0
            for (var j=i+1; j<ary.length; j++) {
                if (ary[j] != 0) break;
            }
            if (ary[i] != ary[j]) {
                ary1.push(ary[i]);
            } else {
                ary1.push(ary[i] + ary[j]);
                i = j;
            }
        }

    }


    for ( ink = 0; ink < 4; ink++) {
        let element = arr1[ink];
        imgs[element].setAttribute('src','./img/cube_'+ ary1[ink] + '.png');
        
    }
     


    
}